<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> - 修改个人信息</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="../favicon.ico">
    <link href="/Public/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/Public/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/css/animate.css" rel="stylesheet">
    <link href="/Public/css/style.css?v=4.1.0" rel="stylesheet">

    <style>
        .btn-primary {

            background-color: #31b0d5;
            border-color: #31b0d5;
        }

        .btn-primary:hover{

            background-color: #31b0d5;
            border-color: #31b0d5;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>账号管理-
                        <small>修改账号</small>
                    </h5>
                </div>
                <div class="ibox-content">
                    <form method="post" class="form-horizontal" onsubmit="return false">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*登录账号</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" placeholder="请输入登录账号【为手机号码】" id="phone" value="<{$data.phone}>" readonly>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" placeholder="请输入管理员名字" id="name"  value="<{$data.name}>" readonly>
                            </div>
                        </div>

            <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*今日回复量：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" placeholder="总在线回复量" id="today"  value="<{$today}>" readonly>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*旧密码</label>
                                <div class="col-sm-10">
                                    <input type="password" class="form-control" placeholder="请输入旧密码" id="oldpwd">
                                </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">*新密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" placeholder="请输入新密码" id="newpwd">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">*确认新密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" placeholder="请输入确认新密码" id="newpwd2">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onclick="adm_save_submit()">修改</button>
                            </div>
                            <!--<div class="col-sm-4 col-sm-offset-2">-->
                            <!--</div>-->
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">绑定接听坐席</label>
                            <div class="col-sm-10">
                                <input type="number" class="" placeholder="请输入坐席号" id="agent">
                                <button class="btn btn-primary" type="button" onclick="edit_agent()">绑定坐席</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="/Public/js/jquery.min.js?v=2.1.4"></script>
<script src="/Public/js/bootstrap.min.js?v=3.3.6"></script>
<!-- 自定义js -->
<script src="/Public/js/content.js?v=1.0.0"></script>
<script src="/Public/js/plugins/layer/layer.min.js"></script>

<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->

<script>
    function edit_agent() {
        //加载loading层
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        var url="<{$SERVER_NAME}>/Admin/edit_agent";
        var agent=document.getElementById("agent").value;
        $.post(url,{agent:agent},function (data){
            console.log('8787878',data);
          if(data.code=='1001'){
              layer.msg('绑定成功', {icon: 6, time: 1000});
              layer.close(index);
          }else {
              layer.close(index);
              layer.msg(data.result, {icon: 5, time: 1000});
          }
        },'json');
        layer.close(index);
    }

    var editadmdata="<{:U('Admin/Admin/editpwdfunc','','html')}>";
    //提交
    var op=1;
    var picop=3;
    function adm_save_submit() {
        //加载loading层
        var index = layer.load(1, {
            shade: [0.1,'#fff'] //0.1透明度的白色背景
        });
        if(op==1) {
            op=2;
            var id='<{$data.id}>';
            var name= $("#name").val();
            var oldpwd= $("#oldpwd").val();
            var newpwd= $("#newpwd").val();
            var newpwd2= $("#newpwd2").val();
            var phone='<{$data.phone}>';
            if (name == null ||name == "") {
                op=1;
                layer.close(index);
                layer.alert("账号昵称不能为空！\r\n", {
                    title: '提示框',
                    icon: 0,
                });
                return false;
            }
            if (oldpwd == null ||oldpwd == "") {
                op=1;
                layer.close(index);
                layer.alert("旧密码不能为空！\r\n", {
                    title: '提示框',
                    icon: 0,
                });
                return false;
            }
            if (newpwd == null ||newpwd == "") {
                op=1;
                layer.close(index);
                layer.alert("新密码不能为空！\r\n", {
                    title: '提示框',
                    icon: 0,
                });
                return false;
            }
            if(newpwd!=newpwd2){
                op=1;
                layer.close(index);
                layer.alert("新密码两次输入不一致！\r\n", {
                    title: '提示框',
                    icon: 0,
                });
                return false;
            }

            $.post(editadmdata, {
                    id:id,
                    name:name,
                    oldpwd:oldpwd,
                    newpwd:newpwd,
                    phone:phone
                },
                function (data) {
                    if (data.state == '1') {
                        layer.msg('修改成功!', {icon: 6, time: 1000});
                        window.location = "<{:U('Admin/Login/logout','','html')}>";
                        op=1;
                        layer.close(index);
                    } else if (data.state == '2') {
                        op=1;
                        layer.close(index);
                        layer.msg(data.msg, {icon: 5, time: 1000});
                    }
                }, 'json');
        }
    }

</script>
</body>
</html>
